#define _GNU_SOURCE
#include "app_pool.h"
#include "log/log.h"
#include <stdlib.h>
#include <unistd.h>

int task_fun(void *arg) {
    char *name = (char *)arg;
    log_debug("线程池中的线程(%d)执行任务函数，参数为：%s", gettid(), name);
    return 0;
}

int main(int argc, char const *argv[])
{
    // 初始化
    app_pool_init(5);

    // 添加任务
    for (int i = 0; i < 10; i++) {
        char *name = malloc(10);
        sprintf(name, "aaa_%d", i+1);

        app_pool_addTask(task_fun, name);
    }

    // 等待任务完成
    sleep(1);
    app_pool_destroy();

    return 0;
}
